]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
popup-menu: Add minimal handling of open/close to Sections
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 7 Oct 2011 18:17:44 +0000 (20:17 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 3 Nov 2011 14:36:57 +0000 (15:36 +0100)
SubMenuMenuItems close automatically with their parent, however
closing fails when the parent item is a MenuSection, as those
currently ignore any open()/close() requests.
At some minimal handling by emitting the 'open-state-changed' signal,
so children like SubMenuMenuItems work as expected.

https://bugzilla.gnome.org/show_bug.cgi?id=661029

js/ui/popupMenu.js

index 2b5a3d9f85eed63a2569d70919e2d4aeca007631..e5e992174e89f6ab1fa658da5aa9434f9742e0bb 100644 (file)
@@ -1019,6 +1019,11 @@ PopupMenuBase.prototype = {
         }
         if (menuItem instanceof PopupMenuSection) {
             this._connectSubMenuSignals(menuItem, menuItem);
+            menuItem._closingId = this.connect('open-state-changed',
+                function(self, open) {
+                    if (!open)
+                        menuItem.close(false);
+                });
             menuItem.connect('destroy', Lang.bind(this, function() {
                 menuItem.disconnect(menuItem._subMenuActivateId);
                 menuItem.disconnect(menuItem._subMenuActiveChangeId);
@@ -1418,9 +1423,10 @@ PopupMenuSection.prototype = {
         this.isOpen = true;
     },
 
-    // deliberately ignore any attempt to open() or close()
-    open: function(animate) { },
-    close: function() { },
+    // deliberately ignore any attempt to open() or close(), but emit the
+    // corresponding signal so children can still pick it up
+    open: function(animate) { this.emit('open-state-changed', true); },
+    close: function() { this.emit('open-state-changed', false); },
 }
 
 function PopupSubMenuMenuItem() {